feat: add maxInlineSize option for size-based asset inlining#1378
Open
bartekkrok wants to merge 1 commit intocallstack:mainfrom
Open
feat: add maxInlineSize option for size-based asset inlining#1378bartekkrok wants to merge 1 commit intocallstack:mainfrom
bartekkrok wants to merge 1 commit intocallstack:mainfrom
Conversation
Assets whose largest scale variant is within the threshold are inlined as base64 URIs; larger assets are extracted as separate files. The option is supported in both the assets-loader directly and via getAssetTransformRules.
|
@bartekkrok is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently, the assets loader only supports two modes for asset delivery: always
extract as separate files or always inline as base64 URIs. There is no way to
automatically inline small assets (where the base64 overhead is negligible) while
still extracting large ones — developers had to choose one strategy for all assets
or manually split rules by path.
This PR adds a maxInlineSize option (in bytes) to both assets-loader and
getAssetTransformRules. Assets whose largest scale variant is within the threshold
are inlined as base64 URIs; larger assets are extracted as separate files. The
comparison uses the largest scale variant (e.g. @3x) intentionally — when an asset
is inlined, all variants are embedded in the bundle, so the largest one determines
the worst-case size impact.
Test plan
React Native screen.
asset is extracted as a separate file.
up for manual validation.
getAssetTransformRules({ maxInlineSize: ... }).